﻿ using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.Mvc;
using DtCms.Common;
 using FineUIMvc;

 namespace BoYuan.FineUIMvcWeb.Controllers
{
    public class HomeController : BaseController
    {
        public ActionResult Index()
        {
            return View();
        }

        public ActionResult Hello()
        {
            return View();
        }

        [HttpPost]
        [ValidateAntiForgeryToken]
        public ActionResult btnHello_Click(FormCollection fc)
        {
            //Alert.Show("你好 FineUI！", MessageBoxIcon.Warning);

            string basepic = "/res/images/basepic.jpg";//背景图
            string watermark = "/res/images/watermark.png";//水印图片(必须是背景透明的png)
            string head = "/res/images/head.jpg";//头像
            string saveUrl = "/new.jpg";

            List<ImageWaterMark.WaterMarkText> list=new List<ImageWaterMark.WaterMarkText>();

            list.Add(new ImageWaterMark.WaterMarkText() {  X = 443, Y = 257 ,Text = fc["f_info"]      });
            list.Add(new ImageWaterMark.WaterMarkText() {  X = 170, Y = 138 ,Text = fc["f_RealName"]  });
            list.Add(new ImageWaterMark.WaterMarkText() {  X = 170, Y = 173 ,Text = fc["f_sex"]       });
            list.Add(new ImageWaterMark.WaterMarkText() {  X = 170, Y = 208 ,Text = fc["f_CardID"]    });
            list.Add(new ImageWaterMark.WaterMarkText() {  X = 170, Y = 244 ,Text = fc["f_language"]  });
            list.Add(new ImageWaterMark.WaterMarkText() {  X = 170, Y = 278 ,Text = fc["f_level"]     });
            list.Add(new ImageWaterMark.WaterMarkText() {  X = 151, Y = 421 ,Text = fc["f_code"]      });
            list.Add(new ImageWaterMark.WaterMarkText() {  X = 509, Y = 445 ,Text = fc["f_date"]      });
            list.Add(new ImageWaterMark.WaterMarkText() {  X = 546, Y = 414 ,Text = fc["f_department"] });
           

            //批量打印文字
            ImageWaterMark.AddImageText(basepic, saveUrl, 100, list);

            //盖章水印
            ImageWaterMark.AddImageSignPic(saveUrl, saveUrl, watermark,9,100,6);

            //头像
            System.Drawing.Image tempImage= ImageWaterMark.PictureProcess(head, 120, 160);
            ImageWaterMark.AddImageSignPicByXY(saveUrl, saveUrl, tempImage,510, 82,100,10);

            tempImage.Dispose();
            

            var img = UIHelper.Image("f_img");
            img.ImageUrl(saveUrl+"?"+DateTime.Now.ToString("fffff"));//刷新图片
            return UIHelper.Result();
        }



        public ActionResult Login()
        {
            return View();
        }

        [HttpPost]
        [ValidateAntiForgeryToken]
        public ActionResult btnLogin_Click(string tbxUserName, string tbxPassword)
        {
            if (tbxUserName == "admin" && tbxPassword == "admin")
            {
                ShowNotify("成功登录！", MessageBoxIcon.Success);
            }
            else
            {
                ShowNotify("用户名或密码错误！", MessageBoxIcon.Error);
            }

            return UIHelper.Result();
        }


        // GET: Themes
        public ActionResult Themes()
        {
            return View();
        }
    }
}